import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
class MyQueue {
    public Stack<Integer> queue1;
    public Stack<Integer> queue2;
    public int size;
    public MyQueue() {
        queue1 =new Stack<>();
        queue2 =new Stack<>();
    }

    public void push(int x) {
        queue1.push(x);
        size++;
    }

    public int pop() {
        if(empty()){
            return -1;
        }
        if(!queue1.isEmpty()){
            int num =queue1.size();
            for(int i=0;i<num;i++){
                queue2.push(queue1.pop());
            }
            size--;
            return queue2.pop();
        }else{
            size--;
            return queue2.pop();
        }
    }

    public int peek() {
        if(empty()){
            return -1;
        }
        if(!queue1.isEmpty()){
            int num =queue1.size();
            for(int i=0;i<num;i++){
                queue2.push(queue1.pop());
            }
            return queue2.peek();
        }else{
            return queue2.peek();
        }
    }
    public boolean empty() {
        return size==0;
    }
}
